<!DOCTYPE HTML>
<html>
<head>
    <title>增加</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <link rel="stylesheet" href="/editor/common.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
    <div id="form1" style="padding-left: 60px">
        <span style="width:60px;display:inline-block;">商品名称：</span>
        <input id="btnEdit1" class="mini-buttonedit" onbuttonclick="onButtonEdit"  name="a" textName="b"/>
    </div>
    <div style="margin: 30px 0;text-align: center">
        <a class="mini-button " iconCls="icon-ok" onclick="addScoreGoodShop()">确定</a>
        <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
    </div>
</body>
<script>
    function addScoreGoodShop(){
        var form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false) {
            alert("请正确填写数据")
            return
        };
        var shopGoodsOId = mini.get("btnEdit1").getValue();
        $.ajax({
            type: "POST",
            url: "/getdata/addShopGoodRecommend",
            data:{
                shopGoodsOId
            },

            success: function (result) {
                if(result =="1"){
                    alert("保存成功");
                    CloseWindow("save");
                }else{
                    alert("保存失敗")
                    CloseWindow("save");
                }

            }
        })
    }

    function CloseWindow(action) {
        if (action == "close" && form.isChanged()) {
            if (confirm("数据被修改了，是否先保存？")) {
                return false;
            }
        }
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }

    function onCancel(e) {
        CloseWindow("cancel");
    }

    function onButtonEdit(e) {
        var btnEdit = this;
        mini.open({
            url: "/editor/shopGoodsChoice",
            title: "商品列表",
            width: 1100,
            height: 450,
            ondestroy: function (action) {
                if (action == "ok") {
                    var iframe = this.getIFrameEl();
                    var data = iframe.contentWindow.GetData();
                    data = mini.clone(data);    //必须
                    if (data) {
                        btnEdit.setText(data.text);
                        btnEdit.setValue(data.id);
                    }
                }else {
                    btnEdit.setText("");
                }

            }
        });

    }
</script>
</html>